import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus, {ElMessage} from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import "@/global/styles/index.scss"
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import 'virtual:svg-icons-register'
import components from '@/global/components.ts'
import 'element-plus/theme-chalk/dark/css-vars.css'
// 添加暗黑模式状态管理





const app = createApp(App)

app.use(ElementPlus, { locale: zhCn })
app.use(components)
app.use(createPinia())
app.use(router)

// 全局错误捕获
app.config.errorHandler = (err) => {
  console.error('[全局错误]', err)
  ElMessage.error("[全局错误]"+err.message)
}

app.mount('#app')

console.log('[APP] 应用初始化完成')
